package com.yxzc.chapter03.forexample

import scala.util.control.Breaks.{break, breakable}

/**
 *
 * @author wu
 * @create 2021-09-01-18:02 
 */
object ForDemo {
  def main(args: Array[String]): Unit = {
    val start = 1
    val end = 5

    /*var list = List("hello",3,19,"tom")
    for (item <- list){
      println("item ="+item)
    }*/
    /*for(i<- start until end if i==2){
      println(i)
    }*/
    /*for(i<- start until end; j = i+1){
      println(i,j)
    }*/
    /* for(i<- start until end;j <-start until end){
       println("i = "+i+"j = "+j)
     }*/

    /*var res = for (i <- start to end) yield {
      if (i % 2 == 0) {
        i
      } else {
        "不是偶数"
      }

      println(res) //Vector(1, 2, 3, 4, 5)
    }*/
    var n = 1
    breakable {
      while (n <= 20) {
        n += 1
        println("n= " + n)
        if (n == 19) {
          break()
        }
      }
    }


  }
}
